package junit;


import org.junit.Test;
import org.ssssssss.script.MagicScript;
import org.ssssssss.script.parsing.Parser;
import org.ssssssss.script.parsing.VarIndex;
import org.ssssssss.script.parsing.ast.Node;

import javax.script.ScriptEngine;
import java.util.List;
import java.util.Set;

/**
 * @author zgn
 * @Description: 模板Junit
 * @date 2022/1/13 0013
 */
public class 脚本Junit {
    @Test
    public void egMin() {//e.g.
        System.out.println();
    }

    @Test
    public void 创建脚本环境_2023年2月7日_lambda_egMin() {//e.g.
        String DEBUG_MARK = "!# DEBUG\r\n",
                source="var a = 1;\n" +
                        "var b = \"123\";\n" +
                        "var c = 456L;\n" +
                        "var d = true;\n" +
                        "var e = null;\n" +
                        "e = c;\n" +
                        "a = b;\n" +
                        "c = false;\n" +
                        "var d = [1,2,3,4,5,a,b,c,d,e,false];\n" +
                        "var map = {\n" +
                        "    k1: 123,\n" +
                        "    k2: \"456\",\n" +
                        "    [b]: false,\n" +
                        "}\n" +
                        "map.k1 = 555;\n" +
                        "map.k1 = 999;\n" +
                        "return a + c + b +d[10];";

        boolean expression=false;

        ScriptEngine scriptEngine=null;

        Parser parser = new Parser();
        boolean debug = source.startsWith(DEBUG_MARK);
        String script = debug ? source.substring(DEBUG_MARK.length()) : source;
        List<Node> nodes = parser.parse(expression ? "return " + script : script);
        Set<VarIndex> varIndices = parser.getVarIndices();

        System.out.println(1);

        //MagicScript magicScript = new MagicScript(nodes, varIndices, scriptEngine, debug);
    }

    @Test
    public void egMax() {//e.g.
        //region 模拟数据
        System.out.println("--------------------Start--------------------");
        //endregion

        //region 数据处理
        System.out.println("--------------------Deal--------------------");
        //endregion

        //region 数据展示
        System.out.println("--------------------Done--------------------");
        //endregion
    }
}
